package com.ffcs.ssh.web.base;

import java.util.List;

import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;

import com.ffcs.ssh.common.web.StrutsAction;
import com.ffcs.ssh.entity.base.Role;
import com.ffcs.ssh.entity.base.User;
import com.ffcs.ssh.service.base.RoleManager;
import com.ffcs.ssh.service.base.UserManager;

@Results({@Result(name=StrutsAction.RELOAD,location="user.action",type=StrutsAction.REDIRECT)})
public class UserAction extends StrutsAction<User>{

	//查询条件
	private String username;
	private String role_id;
	
	@Autowired
	private UserManager userManager;
	@Autowired
	private RoleManager roleManager;
	
	@Override
	protected void doListEntity() throws Exception {
		list = userManager.queryResult(getRequest());
	}
	
	/**
	 * 查询条件里:所有的角色. allRoles根据get方法,这里方法名为:getAllRoles.
	 * 不需要定义成员变量List<Role> allRoles;然后在该方法和doListEntity()里allRoles = roleManager.getRoles();
	 */
	public List<Role> getAllRoles(){
		return roleManager.getAllRoles();
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getRole_id() {
		return role_id;
	}

	public void setRole_id(String role_id) {
		this.role_id = role_id;
	}
}
